package net.stogi.unicore.beyond.ui.server.taskeditor.action.handler;

import net.stogi.common.gwt.dispatch.server.core.ActionHandler;
import net.stogi.common.gwt.dispatch.shared.exception.ActionException;
import net.stogi.unicore.beyond.api.service.TaskService;
import net.stogi.unicore.beyond.ui.shared.taskeditor.action.model.LoadOutputTypesAction;
import net.stogi.unicore.beyond.ui.shared.taskeditor.action.model.LoadOutputTypesResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component("UnicoreBeyondUi.Dispatch.LoadOutputTypesActionHandler")
public class LoadOutputTypesActionHandler implements ActionHandler<LoadOutputTypesAction, LoadOutputTypesResult> {

	@Autowired
	private TaskService taskService;
	
	@Override
	public LoadOutputTypesResult execute(LoadOutputTypesAction action) throws ActionException {
		return new LoadOutputTypesResult(taskService.listOutputTypes());
	}

	@Override
	public Class<LoadOutputTypesAction> getActionType() {
		return LoadOutputTypesAction.class;
	}

	@Override
	public void rollback(LoadOutputTypesAction action, LoadOutputTypesResult result) throws ActionException {}
}
